package com.qd.common.panda.domain.entity.wallet.publish;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.qd.common.panda.domain.entity.wallet.plan.PlanDTO;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Optional;


/**
 * 套餐列表
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class PlanPublishListDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "套餐列表ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "套餐列表ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String publishListId;
    /**
     * 序号
     */
    private Integer idx;
    /**
     * 套餐发布ID
     */
    @Size(max = 50, message = "套餐发布ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String publishId;
    /**
     * 套餐编码
     */
    @NotBlank(message = "套餐编码不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "套餐编码长度不能超过{max}位", groups = DefaultGroup.class)
    private String planCode;
    /**
     * 套餐信息
     */
    private PlanDTO planDTO;

    @Override
    public void freeData() {
        this.publishListId = null;
        this.idx = null;
        this.publishId = null;
        this.planCode = null;
        Optional.ofNullable(planDTO).ifPresent(PlanDTO::freeData);
        super.freeData();
    }
}
